package com.sky.controller.admin;

import com.sky.entity.MeetingRoom;
import com.sky.result.PageResult;
import com.sky.result.Result;
import com.sky.service.MeetingRoomService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@CrossOrigin
@RequestMapping("/admin/meetingRoom")
@Api(tags = "会议室相关接口")
public class RoomController {
    @Autowired
    private MeetingRoomService meetingRoomService;
    @GetMapping("/page/{page}/{size}")
    @ApiOperation("分页查询会议室")
    public Result<PageResult> page(@PathVariable Integer page,@PathVariable Integer size){
        PageResult page1 = meetingRoomService.page(page,size);
        return Result.success(page1);
    }

    @ApiOperation("修改会议室")
    @PutMapping
    public Result update(@RequestBody MeetingRoom meetingRoom){
        meetingRoomService.update(meetingRoom);
        return Result.success();
    }

    @ApiOperation("删除会议室")
    @DeleteMapping("/{id}")
    public Result delete(@PathVariable Integer id){
        meetingRoomService.deleteByid(id);
        return Result.success();
    }

    @ApiOperation("新增会议室")
    @PostMapping
    public Result insert(@RequestBody MeetingRoom meetingRoom){
        meetingRoomService.insert(meetingRoom);
        return Result.success();
    }
}
